#pragma once
#include <d3dx9.h>

const int DEFAULTROWS = 65;
const int DEFAULTCOLS = 65;

typedef D3DXVECTOR3 vec3;

struct TreeNode
{
	TreeNode():inFrustum(true),ilodLevel(0){
		pParent = NULL;
		for(int i = 0;i!=4;++i){ Child[i] = NULL; }
	}
	bool inFrustum;
	int ilodLevel;
	int rows,cols;
	float width,depth;
	vec3 center;

	TreeNode* pParent;
	TreeNode* Child[4];
};

class cQuadTree
{
public:
	cQuadTree(TreeNode* pRoot);
	~cQuadTree();
	void GenerateTree(TreeNode* node,int rows,int cols,float width,float depth,vec3 center);
	void DeleteTree(TreeNode* node);
	TreeNode* GetRoot(){ return m_pRoot; }
private:
	cQuadTree();
	TreeNode* m_pRoot;
};